package com.walk.zworld.ui.activity.my

import android.annotation.SuppressLint
import android.os.Build
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
import com.walk.zworld.R
import com.walk.zworld.webView.WebViewActivity
import com.base.lib.base.view.BaseActivity
import com.walk.zworld.BuildConfig

class AboutActivity : BaseActivity(), View.OnClickListener {

    private lateinit var tv_version_name: TextView
    private lateinit var ll_wan_web: TextView
    private lateinit var ll_web_content: LinearLayout
    private lateinit var ll_source_code: LinearLayout
    private lateinit var ll_statement: LinearLayout

    override fun initData() {}

    override fun onBindLayout(): Int = R.layout.activity_about

    @SuppressLint("SetTextI18n")
    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    override fun initView() {
        setTop("关于")
        tv_version_name = findViewById(R.id.tv_version_name)
        ll_wan_web = findViewById(R.id.ll_wan_web)
        ll_web_content = findViewById(R.id.ll_web_content)
        ll_source_code = findViewById(R.id.ll_source_code)
        ll_statement = findViewById(R.id.ll_statement)

        tv_version_name.text = "Version " + BuildConfig.VERSION_NAME
        ll_wan_web.setOnClickListener(this)
        ll_web_content.setOnClickListener(this)
        ll_source_code.setOnClickListener(this)
        ll_statement.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v) {
            ll_wan_web -> WebViewActivity.start(this, "https://www.wanandroid.com")
            ll_web_content -> WebViewActivity.start(this, "https://www.wanandroid.com/about")
            ll_source_code -> WebViewActivity.start(this, "https://github.com/jzh1996/mvvm")
            ll_statement -> {
                AlertDialog.Builder(this)
                    .setTitle("版权声明")
                    .setMessage(resources.getString(R.string.copyright_content))
                    .setCancelable(true)
                    .show()
            }
        }
    }


}